#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include "Service.h"
#include "Private.h"
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>

/// <summary>
/// TODO
/// </summary>
int StartShell(void)
{
	pid_t pid;
	printf("Executing crash shell...\n");
	//sleep(10);

	if ((pid = fork()) < 0)
		printf("Failed to fork off crash shell: %s", strerror(errno));

	else if (pid == 0)
	{
		int fd = -1;
		if ((fd = OpenConsole(O_RDWR|O_NOCTTY|O_NONBLOCK)) < 0)
			printf("Error: Open Console!\n");
		execl("/bin/sh", "/bin/sh", NULL);
		_exit(1);
	}

	return 0;
}